package top.withwings.bonus.common.pojo;

import java.util.Collections;
import java.util.List;

public class PagedData<T> {

    private List<T> data;
    private int total;//总条数

    private PagedData() {
    }

    public PagedData(List<T> data, int total) {
        this.data = data;
        this.total = total;
    }
    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public static <T> PagedData<T> emptyPage() {
        PagedData<T> empty = new PagedData<>();
        empty.setData(Collections.emptyList());
        empty.setTotal(0);
        return empty;
    }


    public static <T> PagedData<T> create(List<T> data, int total) {
        PagedData<T> page = new PagedData<>();
        page.setData(data);
        page.setTotal(total);
        return page;
    }

}
